package com.square.service.member.provider.controller.rpc;

import com.baomidou.mybatisplus.extension.api.R;
import com.square.service.member.provider.service.UserService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.constraints.NotBlank;

/**
 * 用户控制层
 * 内网提供消费者调用
 *
 * @author : 王苏
 * @since : 2021/4/20 10:58
 */
@Validated
@RestController
@RequestMapping("/rpc/user")
public class UserRPC {

    @Resource
    private UserService userService;

    /**
     * 通过用户名获取用户
     *
     * @param username
     * @return
     */
    @GetMapping("/getUserByUsername")
    public R<?> getUserByUsername(@RequestParam("username") @NotBlank(message = "用户名空指针") String username) {
        return userService.getUserByUsername(username);
    }
}
